<template>
    <div class="container" v-loading="loading">
        <!-- 中转页面 -->
    </div>
</template>
<script setup>
import { ref, onMounted,onBeforeUnmount } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const loading = ref(true)

onMounted(() => {
    window.electron.ipcRenderer.send('getConfig', JSON.stringify({}));
    window.electron.ipcRenderer.on('config', handleConfigResponse);
    window.electron.ipcRenderer.on('set-route', (event, route) => {
        router.push(route)
    });
});
const handleConfigResponse = (event, arg) => {
    if (arg === '无') { // 假设 '无' 表示没有配置，改为 'noConfig' 或其他有意义的字符串
        router.push('/menu');
    } else {
        try {
            let obj = JSON.parse(arg);
            if (obj?.mode?.url) {
                router.push(obj.mode.url);
            } else {
                router.push('/menu');
            }
        } catch (error) {
            console.error('Error parsing config:', error);
            router.push('/error'); // 假设有一个错误处理页面
        }
    }
};
</script>

<style lang="less" scoped>
.container {
    width: 100%;
    height: 100%;
}
</style>